using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using dotnet_ef_admin.Src.Utilities;

namespace dotnet_ef_admin.Src.Models;

[Table("dept")]
public class Dept {
    [Key] public int Id { get; set; }

    [Required] public required string Name { get; set; }

    [Column("parent_id")] public int ParentId { get; set; } = 0;

    [Column("tree_path")] public string? TreePath { get; set; }

    public int? Sort { get; set; } = 0;

    public int Status { get; set; } = 1;

    public int? Deleted { get; set; } = 0;

    [Column("create_time")] public string? CreateTime { get; set; } = DateTimeUtils.GetCurrentTimeString();

    [Column("update_time")] public string? UpdateTime { get; set; }

    [Column("create_by")] public int? CreateBy { get; set; }

    [Column("update_by")] public int? UpdateBy { get; set; }

    public void MarkAsDeleted() {
        (Deleted, UpdateTime) = (1, DateTimeUtils.GetCurrentTimeString());
    }
}